using UnityEngine;
using System;

/**
 * create check button to realize GUIShop
 * author: 	tzz
 * date:	2012-8-29
 */ 
[AddComponentMenu("EZ GUI/Controls/CheckButton")]
public class UICheckButton : UIButton
{
	//! checked state
	private bool m_checked = false;
	
	[HideInInspector] public bool Checked{
		get{return m_checked;}
		set{
			if(m_checked != value){
				m_checked = value;
				SetControlState(m_checked?m_ctrlState:CONTROL_STATE.NORMAL);	
			}
		}
	}
	
	/**
	 * override the set the state by current state
	 */ 
	public override void SetControlState(CONTROL_STATE s, bool suppressTransitions){
		base.SetControlState(m_checked ? UIButton.CONTROL_STATE.ACTIVE : UIButton.CONTROL_STATE.NORMAL,suppressTransitions);
	}
	
	new static public UICheckButton Create(string name, Vector3 pos)
	{
		GameObject go = new GameObject(name);
		go.transform.position = pos;
		return (UICheckButton)go.AddComponent(typeof(UICheckButton));
	}

	new static public UICheckButton Create(string name, Vector3 pos, Quaternion rotation)
	{
		GameObject go = new GameObject(name);
		go.transform.position = pos;
		go.transform.rotation = rotation;
		return (UICheckButton)go.AddComponent(typeof(UICheckButton));
	}
}

